// 工具函数：更新步骤指示器
export function updateStepIndicator(step) {
    const progressStep1 = document.getElementById('progressStep1');
    const progressStep2 = document.getElementById('progressStep2');
    const step2 = document.getElementById('step2');
    const step2Text = document.getElementById('step2Text');
    const step3 = document.getElementById('step3');
    const step3Text = document.getElementById('step3Text');

    switch(step) {
        case 1: // 上传完成，进入识别
            progressStep1.classList.add('scale-x-100');
            step2.classList.replace('bg-neutral-200', 'bg-primary');
            step2.classList.replace('text-neutral-500', 'text-white');
            step2.classList.add('shadow-md');
            step2Text.classList.replace('text-neutral-500', 'text-primary');
            break;
        case 2: // 识别完成，进入生成
            progressStep2.classList.add('scale-x-100');
            step3.classList.replace('bg-neutral-200', 'bg-primary');
            step3.classList.replace('text-neutral-500', 'text-white');
            step3.classList.add('shadow-md');
            step3Text.classList.replace('text-neutral-500', 'text-primary');
            break;
        case 0: // 重置步骤
            progressStep1.classList.remove('scale-x-100');
            progressStep2.classList.remove('scale-x-100');
            // 重置step2和step3样式（略，与原代码一致）
            break;
    }
}

// 工具函数：模拟进度条加载
export function simulateProgress(progressEl, percentageEl, statusEl, statusTexts, callback) {
    let progress = 0;
    const interval = setInterval(() => {
        progress += Math.random() * 15;
        if (progress >= 100) {
            progress = 100;
            clearInterval(interval);
            callback && callback(); // 完成后执行回调
        }
        const statusIndex = Math.min(Math.floor(progress / 20), statusTexts.length - 1);
        statusEl.textContent = statusTexts[statusIndex];
        progressEl.style.transform = `scaleX(${progress / 100})`;
        percentageEl.textContent = `${Math.round(progress)}%`;
    }, 500);
}